package com.yuteng.commons.util;

import cn.hutool.core.util.StrUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取当前用户登录信息的实体类
 *
 * @version 1.0
 * @author： 余腾
 * @date： 2021-10-20 14:11
 */
public class AuthContextHolder {
    /**
     * 获取当前登录用户的id
     *
     * @param request
     * @return
     */
    public static String getUserId(HttpServletRequest request) {
        String userId = request.getHeader("userId");
        return StrUtil.isEmpty(userId) ? "" : userId;
    }

    /**
     * 获取当前未登录临时用户id
     *
     * @param request
     * @return
     */
    public static String getUserTempId(HttpServletRequest request) {
        String userTempId = request.getHeader("userTempId");
        return StrUtil.isEmpty(userTempId) ? "" : userTempId;
    }
}
